/**
 * Copyright ©2016-2020 northkingbpo Corporation, All Rights Reserved
 * http://www.northkingbpo.net/
 */
package profile.hujia.simulation.data.common;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;

/**
 * class info
 *
 * @author hujia
 * @date 2019-06-14 10:58
 */
public class CommonFunction {

    public static List<Integer> createListRandomValues(Integer number, Integer low, Integer high) {
        Random random = new Random();
        List<Integer> values = new ArrayList<>();
        for (int i = 0; i < number; ++i) {
            values.add(random.nextInt(high - low + 1) + low );
        }
        return values;
    }

    public static List<Integer> createUniqueRandomValues(Integer number, Integer low, Integer high) {
        List<Integer> tmpList = new LinkedList<>();
        List<Integer> values = new ArrayList<>();
        Random random = new Random();
        for (int i = 0; i < high - low + 1; ++i) {
            tmpList.add(low + i);
        }
        for (int i = 0; i < number; ++i) {
            Integer pos = random.nextInt(tmpList.size());
            values.add(tmpList.get(pos));
            tmpList.remove(pos.intValue());
        }
        return values;
    }
}
